Under certain conditions, it is a challenge in the field of photography to capture images in which the entire subject matter of the image is sharply in focus. For example, in the field of endoscopy, images of human internal organs are captured and can contain pairs of regions which are at significantly different distances from the camera lens, exceeding the depth of focus of the image capturing device. As a result, in the captured images, at least one of the regions is out of focus.
Focus stacking is a powerful technique for extending the apparent depth of field of an image. Focus stacking combines multiple source images captured at different focus distances to create a resulting composite image with a greater depth of field than each of the individual source images comprising the composite image. No individual source image used to create the composite image will have the subject of the image entirely in focus. However, the individual source images may collectively contain the image data required to create a final composite image that includes all parts of the subject in focus. Using post-processing software, in-focus regions of each individual source image are automatically detected. The in-focus regions are blended together to create a final composite image.